#!/bin/bash

RELEASE_VERSION=%%release_version%%
installed_release="Version-1.2.0"
install_dir=/home/dike
log_dir=$install_dir/audit

_check_sp_dependency ()
{
	echo 'Checking SP dependency...'
	echo "$installed_release" | grep -i "1.2.0"
	if [ "$?" -eq 1 ]
	then
		echo "Missing version 1.2.0, exiting setup"
		touch $install_dir/_demo_failed
		exit 1
	fi
	echo "demo 1.2.0 installed -- OK"
}

_install ()
{
	echo "Installing demo v - $RELEASE_VERSION...."
	cur_path=`pwd`
	echo "current path in additional_scripts/install.sh: $cur_path"
	/bin/bash ../additional_scripts/a1.sh	
	
	echo "demo-$RELEASE_VERSION successfully applied"
}

rm -f $install_dir/_demo_failed
grep "demo-$RELEASE_VERSION successfully applied" "$log_dir"/install.log 2>&1 > /dev/null

if [ "$?" -eq 0 ]
then
	echo "$package_name is already installed. Exiting setup..."
	touch $install_dir/_demo_failed
	exit 1
fi

_check_sp_dependency
_install